<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改一个产品信息</title>
</head>
<body>
<script>
    $(function () {
        $("#editPro-form").form({
            onLoadSuccess:function () {
                $("#hut-pid-update-hidden").next().hide();
            }
        });

        //提交修改表单
        $("#editPro-save").linkbutton({onClick:function () {
                var row = $("#pdg").datagrid("getSelected");
                $("#editPro-form").form({
                    onSubmit:function () {
                        return $(this).form("validate");
                    },
                    success:function (data) {
                        var data = eval("("+data+")");
                        if(data.success){
                            $("#editPro"+row.pid).dialog("close");
                            $.messager.alert("success","修改成功!","info");
                            $("#pdg").datagrid({
                                url:'allProPaged',
                                method:'post'
                            });
                            $("#pdg").datagrid("reload");
                        }else{
                            $.messager.alert("failed",data.message,"error");
                        }
                    }
                }).submit();
            }
        });

        $("#editPro-close").linkbutton({onClick:function () {
                var row = $("#pdg").datagrid("getSelected");
                $("#editPro"+row.pid).dialog("close");
            }});

        $("#editPro-category").combobox({
            onBeforeLoad: function(param){
                if(param == null || param.q == null || param.q.replace(/ /g, '') == ''){
                    var value = $(this).combobox('getValue');
                    if(value){// 修改的时候才会出现q为空而value不为空
                        param.id = value;
                        return true;
                    }
                    return false;
                }

            }
        });
    });
</script>
<div>
    <form id="editPro-form" action="editPro-form-sub" method="post" enctype="multipart/form-data">
        <div class="div-title-hut"> --------------------------------<span class="span-title">修改产品信息</span>---------------------------</div>
        <input id="hut-pid-update-hidden"  name="pid" class="easyui-textbox" data-options="border:false">
        <div class="ddn">
            <input  name="pname" class="easyui-textbox" data-options="label:'产品名称',required:true,width:450">
        </div>
        <div class="ddn">
            <input name="file" class="easyui-filebox" style="width:450px;" data-options="buttonText:'选择图片',prompt:'请选择一张图片'">
        </div>
        <div class="ddn">
            <input id="editPro-category" name="pCategoryname" class="easyui-combobox" data-options="required:false,prompt:'模糊编号及分类名',url:'getAllCategoryBymh',
        label:'产品分类',valueField:'pcid',textField:'pcname',method:'post',editable:true,panelHeight:'auto',width:300,mode:'remote'" ><div style="width: 25px;display: inline-block"></div>
            <input name="pcompany" class="easyui-textbox" data-options="label:'产品厂家',width:300">
        </div>
        <div class="ddn">
            <input name="poprice" class="easyui-textbox" data-options="label:'产品成本价格',width:300"><div style="width: 25px;display: inline-block"></div>
            <input name="pprice" class="easyui-textbox" data-options="label:'产品销售价格',width:300">
        </div>
        <div class="ddn">
            <input name="pbirthday" class="easyui-datebox" data-options="label:'产品生产日期',width:300"><div style="width: 25px;display: inline-block"></div>
            <input name="pouttime" class="easyui-datebox" data-options="label:'产品失效日期',width:300">
        </div>
        <div style="text-align: center; ">
            <input name="ptype" class="easyui-textbox" data-options="label:'产品型号',width:180"><div style="width: 25px;display: inline-block"></div>
            <input name="pspec" class="easyui-textbox" data-options="label:'产品规格',width:180"><div style="width: 25px;display: inline-block"></div>
            <input name="pwunit" class="easyui-textbox" data-options="label:'产品单位',width:180">
        </div>
        <div class="btn ddn">
            <!--此按钮可根据自己业务自行修改或删除-->
            <a id="editPro-save" class="easyui-linkbutton " data-options="iconCls:'icon-ok2'">修改</a><div style="width: 20px;display: inline-block"></div>
            <a id="editPro-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel2'">取消</a>
        </div>
    </form>
</div>
</body>
</html>
